//
//  StatusCellBottomView.swift
//  Weibo
//
//  Created by 孙明海 on 16/1/27.
//  Copyright © 2016年 孙明海. All rights reserved.
//

import UIKit

class StatusCellBottomView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = UIColor(white: 0.9, alpha: 1.0)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    /// 懒加载控件
    ///转发
    private lazy var retweetedButton: UIButton = UIButton(title: " 转发", imageName: "timeline_icon_retweet")
    /// 评论
    private lazy var commentButton: UIButton = UIButton(title: " 评论", imageName: "timeline_icon_comment")
    ///点赞
    private lazy var likeButton: UIButton = UIButton(title: " 赞", imageName: "timeline_icon_unlike")
}
// MARK: - 设置界面
extension StatusCellBottomView {
    private func setupUI() {
        //设置分隔线
        let sepView1 = sepView()
        let sepView2 = sepView()
        let width = 1
        let heigthScale = 0.4
        addSubview(sepView1)
        addSubview(sepView2)
        
        //添加子控件
        addSubview(retweetedButton)
        addSubview(commentButton)
        addSubview(likeButton)
        
        //设置布局
        retweetedButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.bottom.equalTo(self.snp_bottom)
        }
        commentButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetedButton.snp_top)
            make.left.equalTo(retweetedButton.snp_right)
            make.width.equalTo(retweetedButton.snp_width)
            make.height.equalTo(retweetedButton.snp_height)
        }
        likeButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentButton.snp_right)
            make.top.equalTo(commentButton.snp_top)
            make.width.equalTo(commentButton.snp_width)
            make.height.equalTo(commentButton.snp_height)
            make.right.equalTo(self.snp_right)
        }
        
        sepView1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedButton.snp_right)
            make.centerY.equalTo(retweetedButton.snp_centerY)
            make.width.equalTo(width)
            make.height.equalTo(retweetedButton.snp_height).multipliedBy(heigthScale)
        }
        sepView2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentButton.snp_right)
            make.centerY.equalTo(retweetedButton.snp_centerY)
            make.width.equalTo(width)
            make.height.equalTo(retweetedButton.snp_height).multipliedBy(heigthScale)
        }

        
    }
    /// 设置分隔
    ///
    /// - returns: 返回分隔视图
    private func sepView() -> UIView {
        let sepView = UIView()
        sepView.backgroundColor = UIColor.blackColor()
        return sepView
    }
}